package biolabs.space;

import biolabs.model.growth.GrowthDelegate

import scala.collection.JavaConversions._

trait GridShapedObject[
	P <: DiscretePosition[P, C],
	C <: ContinuousPosition[C, P]
] {
	private var shape: GridShape[P, C] = null

	def getShape(): GridShape[P, C] = {
		if(shape == null)
			throw new IllegalStateException("Shape uninitialized")
		else
			shape
	}

	protected def setShape(shape: GridShape[P, C]) {
		this.shape = shape
	}

	protected def init(shape: GridShape[P, C]) {
		this.shape = shape
	}

	def handleGrowth(gd: GrowthDelegate[P]) {
		shape.addElements(gd.elements)
	}
}
